<?php

namespace App\Http\Common\amqp;

use App\Http\Common\amqp\mode\DirectMode;
use App\Http\Common\amqp\mode\FanoutMode;
use App\Http\Common\amqp\mode\HeaderMode;
use App\Http\Common\amqp\mode\TopicMode;

class MQFactory
{
    public static function createMQ(string $type): RabbitMQ
    {
        switch ($type) {
            case DirectMode::class:
                return (new DirectMode());
            case FanoutMode::class:
                return (new FanoutMode());
            case TopicMode::class:
                return (new TopicMode());
            case HeaderMode::class:
                return (new HeaderMode());
            default:
                throw new \Exception("{$type} 不支持该类型");
        }
    }
}
